package com.xiruoyu.domain;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * @author xiruoyu
 * @date 2022/3/13 16:00
 */
public class Employee {
    private String name;

    private BigDecimal sal;

    private MyDate birthday;

    public Employee(String name, BigDecimal sal, MyDate birthday) {
        this.name = name;
        this.sal = sal;
        this.birthday = birthday;
    }

    public Employee() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getSal() {
        return sal;
    }

    public void setSal(BigDecimal sal) {
        this.sal = sal;
    }

    public MyDate getBirthday() {
        return birthday;
    }

    public void setBirthday(MyDate birthday) {
        this.birthday = birthday;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return name.equals(employee.name) && birthday.equals(employee.birthday);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, birthday);
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", sal=" + sal +
                ", birthday=" + birthday +
                '}';
    }

    public static void main(String[] args) {
        Set<Employee> set = new HashSet<Employee>();
        MyDate birthday = new MyDate(2022, 02, 20);
        Employee employee1 = new Employee("张三", new BigDecimal("122"), birthday);
        Employee employee3 = new Employee("张三", new BigDecimal("123"), birthday);
        Employee employee2 = new Employee("李四", new BigDecimal("124"), birthday);
        set.add(employee1);
        set.add(employee2);
        set.add(employee3);
        System.out.println(set);

        ArrayList<Object> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);


    }


}
